//
// Created by Toosan on 2022/4/26.
//
#include "iostream"

using namespace std;

class Person {
protected:
    // string 来自std命名空间，是对 char * 的封装
    string name;
    int age;

public:
    Person(int age, string name) : age(age), name(name) {};
};

class Course {
private:
    string name;
public:
    Course(string name) : name(name) {}

    string getName() {
        return this->name;
    }
};

class Student : public Person {
private:
    /**
     * 对象中的对象成员初始化
     * 对象类型的成员，必须在构造函数的后面初始化
     * 不能通过this->course = course 来初始化。
     */
    Course course;
public:
    Student(int age, string name, Course course) : Person(age, name), course(course) {

    }

    void printfInfo() {
        cout << "name = " << name << ", age = " << age << ", course = " << course.getName() << endl;
    }
};

int main() {
    Course course("computer");
    Student student(17, "Toosan", course);
    student.printfInfo();
    return 0;
}

